package com.zxc.controller.chart;

import com.zxc.entity.CstLost;
import com.zxc.service.CstLostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/chart/drain")
public class CustomerDrainController {

    @Autowired
    private CstLostService cstLostService;

    @RequestMapping(value = "/lost/{pageNo}/{pageSize}")
    @ResponseBody
    public Map<String,Object> getCstLost(@PathVariable(required = false)Integer pageNo,
                                         @PathVariable(required = false)Integer pageSize){
        Map<String,Object> modelMap = new HashMap<>();
        //需要两个数据dataList，数据集   total：数量
        int skipCount = (pageNo-1)*pageSize;
        List<CstLost> cstLostList = cstLostService.getCstLost(skipCount,pageSize);
        modelMap.put("dataList",cstLostList);

        int total = cstLostService.selectCstLostCount();
        modelMap.put("total",total);
        return modelMap;
    }
}
